home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 1997 / HAM Radio 1997.iso / vcls / ras_api / ras_api.pas < prev    next >
Pascal/Delphi Source File  |  1996-04-08  |  12KB  |  283 lines

  1. {$F+}
  2. Unit RAS_API;
  3.  
  4. Interface
  5.  
  6. Uses WinTypes, WinProcs, Dialogs;
  7. { Copyright (c) 1992, Microsoft Corporation, all rights reserved
  8.   Note: The 'dwSize' member of a structure X must be set to sizeof(X)
  9.   before calling the associated API, otherwise ERROR_INVALID_SIZE is
  10.   returned.  The APIs determine the size using 2-byte packing (the
  11.   default for Microsoft compilers when no /Zp<n> option is supplied).
  12.   Users requiring non-default packing can use the 'dwSize' values
  13.   listed next to each 'dwSize' member in place of sizeof(X). }
  14.  
  15. Const
  16.   UNLEN = 20;
  17.   PWLEN = 14;
  18.   DNLEN = 15;
  19.   RAS_MaxEntryName      =  20;
  20.   RAS_MaxDeviceName     =  32;
  21.   RAS_MaxDeviceType     =  16;
  22.   RAS_MaxParamKey       =  32;
  23.   RAS_MaxParamValue     = 128;
  24.   RAS_MaxPhoneNumber    = 128;
  25.   RAS_MaxCallbackNumber =  48;
  26.  
  27. Type
  28.   UINT = Word;
  29.   PHRASConn = ^HRASConn;
  30.   HRASConn = LongInt;
  31.  
  32.  
  33. { Pass this string to the RegisterWindowMessage() API to get the message
  34. ** number that will be used for notifications on the hwnd you pass to the
  35. ** RasDial() API.  WM_RASDIALEVENT is used only if a unique message cannot be
  36. ** registered. }
  37. const
  38.   RASDialEvent = 'RASDialEvent';
  39.   WM_RASDialEvent = $0CCCD;
  40.   { Enumerates intermediate states to a Connection.  (See RasDial) }
  41.   RASCS_Paused = $1000;
  42.   RASCS_Done   = $2000;
  43.  
  44.   RASBase = 600;
  45.   Success = 0;
  46. { Error Codes }
  47.   PENDING                              = (RASBase+0);
  48.   ERROR_INVALID_PORT_HANDLE            = (RASBase+1);
  49.   ERROR_PORT_ALREADY_OPEN              = (RASBase+2);
  50.   ERROR_BUFFER_TOO_SMALL               = (RASBase+3);
  51.   ERROR_WRONG_INFO_SPECIFIED           = (RASBase+4);
  52.   ERROR_CANNOT_SET_PORT_INFO           = (RASBase+5);
  53.   ERROR_PORT_NOT_ConnECTED             = (RASBase+6);
  54.   ERROR_EVENT_INVALID                  = (RASBase+7);
  55.   ERROR_DEVICE_DOES_NOT_EXIST          = (RASBase+8);
  56.   ERROR_DEVICETYPE_DOES_NOT_EXIST      = (RASBase+9);
  57.   ERROR_INVALID_BUFFER                 = (RASBase+10);
  58.   ERROR_ROUTE_NOT_AVAILABLE            = (RASBase+11);
  59.   ERROR_ROUTE_NOT_ALLOCATED            = (RASBase+12);
  60.   ERROR_INVALID_COMPRESSION_SPECIFIED  = (RASBase+13);
  61.   ERROR_OUT_OF_BUFFERS                 = (RASBase+14);
  62.   ERROR_PORT_NOT_FOUND                 = (RASBase+15);
  63.   ERROR_ASYNC_REQUEST_PENDING          = (RASBase+16);
  64.   ERROR_ALREADY_DISConnECTING          = (RASBase+17);
  65.   ERROR_PORT_NOT_OPEN                  = (RASBase+18);
  66.   ERROR_PORT_DISConnECTED              = (RASBase+19);
  67.   ERROR_NO_ENDPOINTS                   = (RASBase+20);
  68.   ERROR_CANNOT_OPEN_PHONEBOOK          = (RASBase+21);
  69.   ERROR_CANNOT_LOAD_PHONEBOOK          = (RASBase+22);
  70.   ERROR_CANNOT_FIND_PHONEBOOK_ENTRY    = (RASBase+23);
  71.   ERROR_CANNOT_WRITE_PHONEBOOK         = (RASBase+24);
  72.   ERROR_CORRUPT_PHONEBOOK              = (RASBase+25);
  73.   ERROR_CANNOT_LOAD_STRING             = (RASBase+26);
  74.   ERROR_KEY_NOT_FOUND                  = (RASBase+27);
  75.   ERROR_DISConnECTION                  = (RASBase+28);
  76.   ERROR_REMOTE_DISConnECTION           = (RASBase+29);
  77.   ERROR_HARDWARE_FAILURE               = (RASBase+30);
  78.   ERROR_USER_DISConnECTION             = (RASBase+31);
  79.   ERROR_INVALID_SIZE                   = (RASBase+32);
  80.   ERROR_PORT_NOT_AVAILABLE             = (RASBase+33);
  81.   ERROR_CANNOT_PROJECT_CLIENT          = (RASBase+34);
  82.   ERROR_UNKNOWN                        = (RASBase+35);
  83.   ERROR_WRONG_DEVICE_ATTACHED          = (RASBase+36);
  84.   ERROR_BAD_STRING                     = (RASBase+37);
  85.   ERROR_REQUEST_TIMEOUT                = (RASBase+38);
  86.   ERROR_CANNOT_GET_LANA                = (RASBase+39);
  87.   ERROR_NETBIOS_ERROR                  = (RASBase+40);
  88.   ERROR_SERVER_OUT_OF_RESOURCES        = (RASBase+41);
  89.   ERROR_NAME_EXISTS_ON_NET             = (RASBase+42);
  90.   ERROR_SERVER_GENERAL_NET_FAILURE     = (RASBase+43);
  91.   WARNING_MSG_ALIAS_NOT_ADDED          = (RASBase+44);
  92.   ERROR_AUTH_INTERNAL                  = (RASBase+45);
  93.   ERROR_RESTRICTED_LOGON_HOURS         = (RASBase+46);
  94.   ERROR_ACCT_DISABLED                  = (RASBase+47);
  95.   ERROR_PASSWD_EXPIRED                 = (RASBase+48);
  96.   ERROR_NO_DIALIN_PERMISSION           = (RASBase+49);
  97.   ERROR_SERVER_NOT_RESPONDING          = (RASBase+50);
  98.   ERROR_FROM_DEVICE                    = (RASBase+51);
  99.   ERROR_UNRECOGNIZED_RESPONSE          = (RASBase+52);
  100.   ERROR_MACRO_NOT_FOUND                = (RASBase+53);
  101.   ERROR_MACRO_NOT_DEFINED              = (RASBase+54);
  102.   ERROR_MESSAGE_MACRO_NOT_FOUND        = (RASBase+55);
  103.   ERROR_DEFAULTOFF_MACRO_NOT_FOUND     = (RASBase+56);
  104.   ERROR_FILE_COULD_NOT_BE_OPENED       = (RASBase+57);
  105.   ERROR_DEVICENAME_TOO_LONG            = (RASBase+58);
  106.   ERROR_DEVICENAME_NOT_FOUND           = (RASBase+59);
  107.   ERROR_NO_RESPONSES                   = (RASBase+60);
  108.   ERROR_NO_COMMAND_FOUND               = (RASBase+61);
  109.   ERROR_WRONG_KEY_SPECIFIED            = (RASBase+62);
  110.   ERROR_UNKNOWN_DEVICE_TYPE            = (RASBase+63);
  111.   ERROR_ALLOCATING_MEMORY              = (RASBase+64);
  112.   ERROR_PORT_NOT_CONFIGURED            = (RASBase+65);
  113.   ERROR_DEVICE_NOT_READY               = (RASBase+66);
  114.   ERROR_READING_INI_FILE               = (RASBase+67);
  115.   ERROR_NO_ConnECTION                  = (RASBase+68);
  116.   ERROR_BAD_USAGE_IN_INI_FILE          = (RASBase+69);
  117.   ERROR_READING_SECTIONNAME            = (RASBase+70);
  118.   ERROR_READING_DEVICETYPE             = (RASBase+71);
  119.   ERROR_READING_DEVICENAME             = (RASBase+72);
  120.   ERROR_READING_USAGE                  = (RASBase+73);
  121.   ERROR_READING_MAXConnECTBPS          = (RASBase+74);
  122.   ERROR_READING_MAXCARRIERBPS          = (RASBase+75);
  123.   ERROR_LINE_BUSY                      = (RASBase+76);
  124.   ERROR_VOICE_ANSWER                   = (RASBase+77);
  125.   ERROR_NO_ANSWER                      = (RASBase+78);
  126.   ERROR_NO_CARRIER                     = (RASBase+79);
  127.   ERROR_NO_DIALTONE                    = (RASBase+80);
  128.   ERROR_IN_COMMAND                     = (RASBase+81);
  129.   ERROR_WRITING_SECTIONNAME            = (RASBase+82);
  130.   ERROR_WRITING_DEVICETYPE             = (RASBase+83);
  131.   ERROR_WRITING_DEVICENAME             = (RASBase+84);
  132.   ERROR_WRITING_MAXConnECTBPS          = (RASBase+85);
  133.   ERROR_WRITING_MAXCARRIERBPS          = (RASBase+86);
  134.   ERROR_WRITING_USAGE                  = (RASBase+87);
  135.   ERROR_WRITING_DEFAULTOFF             = (RASBase+88);
  136.   ERROR_READING_DEFAULTOFF             = (RASBase+89);
  137.   ERROR_EMPTY_INI_FILE                 = (RASBase+90);
  138.   ERROR_AUTHENTICATION_FAILURE         = (RASBase+91);
  139.   ERROR_PORT_OR_DEVICE                 = (RASBase+92);
  140.   ERROR_NOT_BINARY_MACRO               = (RASBase+93);
  141.   ERROR_DCB_NOT_FOUND                  = (RASBase+94);
  142.   ERROR_STATE_MACHINES_NOT_STARTED     = (RASBase+95);
  143.   ERROR_STATE_MACHINES_ALREADY_STARTED = (RASBase+96);
  144.   ERROR_PARTIAL_RESPONSE_LOOPING       = (RASBase+97);
  145.   ERROR_UNKNOWN_RESPONSE_KEY           = (RASBase+98);
  146.   ERROR_RECV_BUF_FULL                  = (RASBase+99);
  147.   ERROR_CMD_TOO_LONG                   = (RASBase+100);
  148.   ERROR_UNSUPPORTED_BPS                = (RASBase+101);
  149.   ERROR_UNEXPECTED_RESPONSE            = (RASBase+102);
  150.   ERROR_INTERACTIVE_MODE               = (RASBase+103);
  151.   ERROR_BAD_CALLBACK_NUMBER            = (RASBase+104);
  152.   ERROR_INVALID_AUTH_STATE             = (RASBase+105);
  153.   ERROR_WRITING_INITBPS                = (RASBase+106);
  154.   ERROR_INVALID_WIN_HANDLE             = (RASBase+107);
  155.   ERROR_NO_PASSWORD                    = (RASBase+108);
  156.   ERROR_NO_USERNAME                    = (RASBase+109);
  157.   ERROR_CANNOT_START_STATE_MACHINE     = (RASBase+110);
  158.   ERROR_GETTING_COMMSTATE              = (RASBase+111);
  159.   ERROR_SETTING_COMMSTATE              = (RASBase+112);
  160.   ERROR_COMM_FUNCTION                  = (RASBase+113);
  161.   ERROR_CONFIGURATION_PROBLEM          = (RASBase+114);
  162.   ERROR_X25_DIAGNOSTIC                 = (RASBase+115);
  163.   ERROR_TOO_MANY_LINE_ERRORS           = (RASBase+116);
  164.   ERROR_OVERRUN                        = (RASBase+117);
  165.   ERROR_ACCT_EXPIRED                   = (RASBase+118);
  166.   ERROR_CHANGING_PASSWORD              = (RASBase+119);
  167.   ERROR_NO_ACTIVE_ISDN_LINES           = (RASBase+120);
  168.   ERROR_NO_ISDN_CHANNELS_AVAILABLE     = (RASBase+121);
  169.  
  170. Const
  171.   RASCS_OpenPort = 0;
  172.   RASCS_PortOpened = 1;
  173.   RASCS_ConnectDevice = 2;
  174.   RASCS_DeviceConnected = 3;
  175.   RASCS_AllDevicesConnected = 4;
  176.   RASCS_Authenticate = 5;
  177.   RASCS_AuthNotify = 6;
  178.   RASCS_AuthRetry = 7;
  179.   RASCS_AuthCallback = 8;
  180.   RASCS_AuthChangePassword = 9;
  181.   RASCS_AuthProject = 10;
  182.   RASCS_AuthLinkSpeed = 11;
  183.   RASCS_AuthAck = 12;
  184.   RASCS_ReAuthenticate = 13;
  185.   RASCS_Authenticated = 14;
  186.   RASCS_PrepareForCallback = 15;
  187.   RASCS_WaitForModemReset = 16;
  188.   RASCS_WaitForCallback = 17;
  189.  
  190.   RASCS_Interactive         = RASCS_Paused;
  191.   RASCS_RetryAuthentication = RASCS_Paused + 1;
  192.   RASCS_CallbackSetByCaller = RASCS_Paused + 2;
  193.   RASCS_PasswordExpired     = RASCS_Paused + 3;
  194.  
  195.   RASCS_Connected    = RASCS_Done;
  196.   RASCS_DisConnected = RASCS_Done + 1;
  197.  
  198. Type
  199. { Identifies an active RAS Connection.  (See RasConnectEnum) }
  200.   PRASConn = ^TRASConn;
  201.   TRASConn = record
  202.      dwSize: LongInt;  { 30 }
  203.      rasConn: HRASConn;
  204.      szEntryName: Array[0..RAS_MaxEntryName] Of Char;
  205.   end;
  206.  
  207.   PRASConnStatus = ^TRASConnStatus;
  208.   TRASConnStatus = Record
  209.     dwSize: LongInt;  { 60 }
  210.     rasConnstate: Word;
  211.     dwError: LongInt;
  212.     szDeviceType: Array[0..RAS_MaxDeviceType] Of Char;
  213.     szDeviceName: Array[0..RAS_MaxDeviceName] Of Char;
  214.   End;
  215.  
  216.   PRASDialParams = ^TRASDialParams;
  217.   TRASDialParams = Record
  218.     dwSize: LongInt;  { 256 }
  219.     szEntryName: Array[0..RAS_MaxEntryName] Of Char;
  220.     szPhoneNumber: Array[0..RAS_MaxPhoneNumber] Of Char;
  221.     szCallbackNumber: Array[0..RAS_MaxCallbackNumber] Of Char;
  222.     szUserName: Array[0..UNLEN] Of Char;
  223.     szPassword: Array[0..PWLEN] Of Char;
  224.     szDomain: Array[0..DNLEN] Of Char;
  225.     Reserved: Byte;
  226.   end;
  227.  
  228.   PRASEntryName = ^TRASEntryName;
  229.   TRASEntryName = Record
  230.     dwSize: LongInt;  { 26 }
  231.     szEntryName: Array[0..RAS_MaxEntryName] Of Char;
  232.     Reserved: Byte;
  233.   End;
  234.  
  235. function RasDial(reserved: PChar;              { reserved; must be set to NULL }
  236.                  szPhonebookPath: PChar;       { full pathname to Phone Book file }
  237.                  rasdialparams: PRASDialParams;{ points to calling parameters }
  238.                  reserved2: Pointer;           { reserved; must be set to NULL}
  239.                  hwndnotifier: HWnd;           { notification message for RasDial events }
  240.                  var rasConn: HRASConn         { points to variable to receive Connection handle}
  241.                  ): LongInt; far;
  242.  
  243.  
  244. function RasEnumConnections(RASConn: PrasConn;       { buffer to receive Connections data }
  245.                             var BufSize: WORD;       { size in bytes of buffer }
  246.                             var Connections: Word    { number of Connections written to buffer }
  247.                             ): LongInt; far;
  248.  
  249. function RasEnumEntries(reserved: PChar;    { reserved; must be NULL }
  250.                         szPhonebookPath: PChar;    { full path to Phone Book file }
  251.                         rasentryname: PRASENTRYNAME;    { buffer to receive Phone Book entries }
  252.                         var BufSize: Word;    { size in bytes of buffer }
  253.                         var Entries: Word     { number of entries written to buffer }
  254.                         ): LongInt; far;
  255.  
  256. function RasGetConnectStatus(RASConn: hrasConn;    { handle to Remote Access Connection of interest }
  257.                              RASConnStatus: PRASConnStatus    { buffer to receive status data }
  258.                              ): LongInt; far;
  259.  
  260. function RasGetErrorString(ErrorCode: Word;    { error code to get string for }
  261.                            szErrorString: PChar;    { buffer to hold error string }
  262.                            BufSize: Word    { sizeof buffer }
  263.                            ): LongInt; far;
  264.  
  265. function RasHangUp(RASConn: hrasConn    { handle to the Remote Access Connection to hang up }
  266.                    ): LongInt; far;
  267.  
  268.  
  269. implementation
  270.  
  271. const
  272.   RAS_DLL = 'RASAPI16';
  273.  
  274. function RasDial; external RAS_DLL;
  275. function RasEnumConnections; external RAS_DLL;
  276. function RasEnumEntries; external RAS_DLL;
  277. function RasGetConnectStatus; external RAS_DLL;
  278. function RasGetErrorString; external RAS_DLL;
  279. function RasHangUp; external RAS_DLL;
  280.  
  281. end.
  282.  
  283.